package display;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.springframework.web.context.*;

import domain.DependienteRepository;
import domain.Dependiente;

public class EliminarDependiente extends PageController {
  
  public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException {

	  DependienteRepository objs = (DependienteRepository) context.getBean("dependienteRepository");
    try {
		String str_pk = request.getParameter("pk_dependiente");
		int pk = Integer.parseInt(str_pk);
		
		Dependiente obj = objs.find(pk);
		try {			
			objs.delete(obj);
		} catch (Exception e) {}
    	response.sendRedirect("listaDependientes");
	} catch (Exception e) {
		request.setAttribute("mensaje",e.getMessage());
		forward("/paginaError.jsp",request,response);
	}
  }
}